#!/bin/bash

# 构建Docker镜像
echo "构建Docker镜像..."
docker rmi link-agent:latest
docker rmi harbor.derucci-smart.com/derucci-smart/link-agent:1.0.0-alpha.3
docker build -t link-agent:latest .
docker tag link-agent:latest harbor.derucci-smart.com/derucci-smart/link-agent:1.0.0-alpha.3
docker push harbor.derucci-smart.com/derucci-smart/link-agent:1.0.0-alpha.3
# 检查构建是否成功
if [ $? -eq 0 ]; then
    echo "镜像构建成功！"
    echo "镜像信息:"
    docker images link-agent:latest
    
    echo ""
    echo "运行方式："
    echo "1. 使用docker run:"
    echo "   docker run -d --name link-agent -e AGENT_SERVER_URL=http://your-server:8080 link-agent:latest"
    echo ""
    echo "2. 使用docker-compose:"
    echo "   docker-compose up -d"
    echo ""
    echo "3. 查看日志:"
    echo "   docker logs -f link-agent"
else
    echo "镜像构建失败！"
    exit 1
fi